/**
 * Title:        Utility Class Library<p>
 * Description:  Some useful utility classes.<p>
 */
package com.timber.util;

import java.text.SimpleDateFormat; //Added by CGI India(Tamil/Aparna)
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import pv.jfcx.*;


/**
 *	MASTER list of most common column definitions.
 *	Extended by actual screen column managers
 *	SLColumnDefinition objects are use by TableModel class.
 *	Should be CLONED as editors and renderers can not be shared across tables !!!!!
 *
 */
public class SLColumnManager
{
	  // Written by CGI India (Tamil/Aparna)

	protected static SimpleDateFormat sdf = new SimpleDateFormat( "dd-MMM-yyyy" );
	static class RowRenderer1 extends PVTableRenderer
	  {
	    public RowRenderer1( int type )
	    {
	      super( type );
	      if( type == JPVTable.COMBO )
		setFormat( SLColumnManager.sdf );
	      
	    }
	  }
	
	  //=======================================
  public static final int COLUMN_ID_START       = 100000;

  public static final int SEC_CODE 		= COLUMN_ID_START +  0;
  public static final int SEC_DESCR 		= COLUMN_ID_START +  1;
  public static final int CPARTY_CODE		= COLUMN_ID_START +  2;
  public static final int CPARTY_NAME		=	 COLUMN_ID_START +  3;
  public static final int ENTITY		= COLUMN_ID_START +  4;
  public static final int COST_CENTER		= COLUMN_ID_START +  5;
  public static final int PROFIT_CENTER		= COLUMN_ID_START +  6;
  public static final int BORROW_LOAN		= COLUMN_ID_START +  7;
  public static final int VALUE			= COLUMN_ID_START +  8;
  public static final int COUNTRY		= COLUMN_ID_START + 10;
  public static final int CURRENCY		= COLUMN_ID_START + 11;
  public static final int QUANTITY		= COLUMN_ID_START + 12;
  public static final int SEC_PRICE		= COLUMN_ID_START + 13;
  public static final int COLLAT_TYPE		= COLUMN_ID_START + 14;
  public static final int MARK_PRICE		= COLUMN_ID_START + 15;
  public static final int FEE			= COLUMN_ID_START + 16;
  public static final int MARGIN		= COLUMN_ID_START + 17;
  public static final int TRADE_CURRENCY	= COLUMN_ID_START + 18;
  public static final int REBATE		= COLUMN_ID_START + 19;
  public static final int OPEN_DATE		= COLUMN_ID_START + 20;
  public static final int SETTLE_DATE		= COLUMN_ID_START + 21;
  public static final int TERM_DATE		= COLUMN_ID_START + 22;
  public static final int DEALER		= COLUMN_ID_START + 23;
  public static final int BARGAIN_REF		= COLUMN_ID_START + 24;
  public static final int UPDATE_DATE		= COLUMN_ID_START + 25;
  public static final int UPDATE_USER		= COLUMN_ID_START + 26;
  public static final int BASE_CURRENCY		= COLUMN_ID_START + 27;
  public static final int BASE_CCY_VALUE	= COLUMN_ID_START + 28;
  public static final int COLLAT_SETTLE_DATE	= COLUMN_ID_START + 29;
  public static final int COLLAT_SETTLE_MODE	= COLUMN_ID_START + 30;
  public static final int RATE			= COLUMN_ID_START + 31;
  public static final int STATUS			= COLUMN_ID_START + 32;
  public static final int DERIVED_FEE		= COLUMN_ID_START + 33;
  public static final int BIZDAY			= COLUMN_ID_START + 34;
  public static final int CA_REC_DATE		= COLUMN_ID_START + 35;
  public static final int CA_TYPE			= COLUMN_ID_START + 36;
  public static final int SEC_CODE_TYPE		= COLUMN_ID_START + 37;
  public static final int CUM_EX			= COLUMN_ID_START + 38;
  public static final int IMG_REF			= COLUMN_ID_START + 39;
  public static final int COF_ADJ			= COLUMN_ID_START + 40;
  public static final int SCRIPT_ELECTION	= COLUMN_ID_START + 41;
  public static final int ORG_SETTLE_DATE	= COLUMN_ID_START + 42;
  public static final int CREST_FOP			= COLUMN_ID_START + 43;
  public static final int EXCH_COUNTRY		= COLUMN_ID_START + 44;
  public static final int ACCOUNT			= COLUMN_ID_START + 45;
  public static final int ACCOUNTNAME		= COLUMN_ID_START + 46;
  public static final int P_AND_L			= COLUMN_ID_START + 47;
  public static final int SPECIAL_FLAG		= COLUMN_ID_START + 48;
  public static final int CLASSIFICATION	= COLUMN_ID_START + 49;
  public static final int REPO_TO			= COLUMN_ID_START + 50;
  public static final int REPO_FROM			= COLUMN_ID_START + 51;
  //Written  by CGI - Bangalore (Tamil/Aparna)
  public static final int SEC_OPTIONS = COLUMN_ID_START + 52 ;
  public static final int SEC_EXPDATE = COLUMN_ID_START + 53;
  //-------------------------

//cgi start added for Data ExploreWindow 
  public static final int WEIGHTED_AVERAGE_FEE = COLUMN_ID_START + 54;
  public static final int LAST_TRADE_DATE = COLUMN_ID_START + 55;
  public static final int LAST_TRADE_QUANTITY = COLUMN_ID_START + 56;
  public static final int LAST_TRADE_REBATE_RATE = COLUMN_ID_START + 57;
  public static final int UTILIZATION_AGE = COLUMN_ID_START + 58;
  public static final int RICCODE = COLUMN_ID_START + 59;
  public static final int CUSIP  = COLUMN_ID_START + 60;
  public static final int SEDOL = COLUMN_ID_START + 61;
  public static final int ISIN = COLUMN_ID_START + 62;
 
  // cgi end added for Data ExploreWindow 
// cgi strta added for DataExlorerAnalytics Panel
  	public static final int SEID  = COLUMN_ID_START + 63;
	public static final int DE_AVAILABILITY = COLUMN_ID_START + 64;

	public static final int DB_AVAILABILITY = COLUMN_ID_START + 65;

	public static final int DE_UTILIZATION = COLUMN_ID_START + 66;

	public static final int DB_AGEOFMARKET = COLUMN_ID_START + 67;

	public static final int DE_WEIGHTED_AVERAGE_FEE = COLUMN_ID_START + 68;

	public static final int DE_MOST_RECENT_EFEE = COLUMN_ID_START + 69;

	public static final int DB_FEE = COLUMN_ID_START + 70;

	public static final int AVG_BORROW_AGE = COLUMN_ID_START + 71;

	public static final int DB_FEE_DESPIRSON = COLUMN_ID_START + 72;

	public static final int NET_DIV_DESPIRSON = COLUMN_ID_START + 73;

	public static final int NET_DIV = COLUMN_ID_START + 74;

	public static final int AGE_UTILIZATION = COLUMN_ID_START + 75;

	public static final int RATE_CHANGE = COLUMN_ID_START + 76;

	public static final int BB_TICKER = COLUMN_ID_START + 77;
	
	public static final int SHORTS_DB_UTILIZATION = COLUMN_ID_START + 78;
	
	public static final int DE_HEIGHEST_FEE = COLUMN_ID_START + 79;

	public static final int DB_MOST_RECENT_EFEE = COLUMN_ID_START + 80;

	public static final int DB_MOST_RECENT_TRADE_SEIZE = COLUMN_ID_START + 81;
	//public static final int  DE_AVAILABILITY= COLUMN_ID_START + 82;


  // cgi  added for DataExlorerAnalytics Panel end
	

  
  private static Hashtable columnMaster         = new Hashtable();
  private static Hashtable columnMasterByIdName = new Hashtable();


  static
  {
    columnMaster.put( new Integer(SEC_CODE), new SLColumnDefinition( SEC_CODE, "Security", "Security", new DefaultSLObjectRenderer(), null, 12 ) );

    columnMaster.put( new Integer(SEC_CODE_TYPE), new SLColumnDefinition( SEC_CODE_TYPE, "SecCodeType", "SecCodeType", new DefaultSLObjectRenderer(), null, 10 ) );

    columnMaster.put( new Integer(SEC_DESCR), new SLColumnDefinition( SEC_DESCR, "SecDescription", "Sec Description", new DefaultSLObjectRenderer(), null, 16 ) );

    columnMaster.put( new Integer(CPARTY_CODE), new SLColumnDefinition( CPARTY_CODE, "Cparty", "Cparty", new DefaultSLObjectRenderer(), null, 6 ) );

    columnMaster.put( new Integer(CPARTY_NAME), new SLColumnDefinition( CPARTY_NAME, 	"CpartyName",  	"Cparty Name", 	new DefaultSLObjectRenderer(), null, 20 ) );

    columnMaster.put( new Integer(ENTITY), new SLColumnDefinition( ENTITY, "Entity", "Entity", new DefaultSLObjectRenderer(), null, 6 ) );

    columnMaster.put( new Integer(COST_CENTER), new SLColumnDefinition( COST_CENTER, "CC", "CC", new DefaultSLObjectRenderer(), null, 6 ) );

    columnMaster.put( new Integer(PROFIT_CENTER), new SLColumnDefinition( PROFIT_CENTER, "PC", "PC", new DefaultSLObjectRenderer(), null, 3 ) );

    columnMaster.put( new Integer(BORROW_LOAN), new SLColumnDefinition( BORROW_LOAN, "BL", "B/L", new DefaultSLObjectRenderer(), null, 3 ) );

    columnMaster.put( new Integer(VALUE), new SLColumnDefinition( VALUE, "Value", "Value", new SLNumberRenderer( JPVTable.DOUBLE, 14, 2 ), null, 14 ) );

    columnMaster.put( new Integer(QUANTITY), new SLColumnDefinition( QUANTITY, "Quantity", "Quantity", new SLNumberRenderer( JPVTable.DOUBLE, 16, Global.usrDecimalPref ), new SLNumberEditor(JPVTable.DOUBLE), 15 ) );

    columnMaster.put( new Integer(COUNTRY), new SLColumnDefinition( COUNTRY, "Cntry", "Cntry", new DefaultSLObjectRenderer(), null, 4 ) );

    columnMaster.put( new Integer(CURRENCY), new SLColumnDefinition( CURRENCY, "CCY", "CCY", new DefaultSLObjectRenderer(), null, 5) );

    columnMaster.put( new Integer(SEC_PRICE), new SLColumnDefinition( SEC_PRICE, "Price", "Price", new SLNumberRenderer( JPVTable.DOUBLE, 10, 4 ), new SLNumberEditor(true), 10 ) );

    columnMaster.put( new Integer(COLLAT_TYPE), new SLColumnDefinition( COLLAT_TYPE, "ClTp", "ClTp", new DefaultSLObjectRenderer(), null, 4 ) );

    columnMaster.put( new Integer(MARK_PRICE), new SLColumnDefinition( MARK_PRICE, "Mark", "Mark", new SLNumberRenderer( JPVTable.DOUBLE, 10, 6, false), new SLNumberEditor(true), 10 ) );

    columnMaster.put( new Integer(RATE), new SLColumnDefinition( RATE, "Rate", "Rate", new SLNumberRenderer( JPVTable.DOUBLE, 10, 4, false ), new SLNumberEditor(true), 10 ) );

    //	actual fee or rebate equivalent
    columnMaster.put( new Integer(FEE), new SLColumnDefinition( FEE, "Fee", "Fee", new SLNumberRenderer( JPVTable.DOUBLE, 7, 4, false ), new SLNumberEditor(true), 7 ) );

    //	includes SL charges
    columnMaster.put( new Integer(DERIVED_FEE), new SLColumnDefinition( DERIVED_FEE, "DrvdFee", "DrvdFee", new SLNumberRenderer( JPVTable.DOUBLE, 7, 4, false ), new SLNumberEditor(true), 7 ) );

    columnMaster.put( new Integer(REBATE), new SLColumnDefinition( REBATE, "Rebate", "Rebate", new SLNumberRenderer( JPVTable.DOUBLE, 7, 4, false ), new SLNumberEditor(true), 7 ) );

    columnMaster.put( new Integer(MARGIN), new SLColumnDefinition( MARGIN, "Margin", "Margin", new SLNumberRenderer( JPVTable.DOUBLE, 4, 2, false ), new SLNumberEditor(true), 6 ) );

    columnMaster.put( new Integer(TRADE_CURRENCY), new SLColumnDefinition( TRADE_CURRENCY, "TrdCCY", "TrdCCY", new DefaultSLObjectRenderer(), null, 6) );

    columnMaster.put( new Integer(OPEN_DATE), new SLColumnDefinition( OPEN_DATE, "OpenDate", "Open Date", new SLDateRenderer(), null, 9 ) );

    columnMaster.put( new Integer(SETTLE_DATE), new SLColumnDefinition( SETTLE_DATE, "SettleDate",  "Settle Date", new SLDateRenderer(), null, 9 ) );

    columnMaster.put( new Integer(TERM_DATE), new SLColumnDefinition( TERM_DATE, "TermDate", "Term Date", new SLDateRenderer(), null, 9 ) );

    columnMaster.put( new Integer(DEALER), new SLColumnDefinition( DEALER, "Dealer", "Dealer", new DefaultSLObjectRenderer(), null, 9 ) );

    columnMaster.put( new Integer(BARGAIN_REF), new SLColumnDefinition( BARGAIN_REF, "BargainRef",  "Bargain Ref", 	new DefaultSLObjectRenderer(), null, 12 ) );

    columnMaster.put( new Integer(UPDATE_DATE), new SLColumnDefinition( UPDATE_DATE, "UpdateDate",  "UpdateDate", 	new SLDateTimeRenderer(), null, 25 ) );

    columnMaster.put( new Integer(UPDATE_USER), new SLColumnDefinition( UPDATE_USER, "UpdateUser",  "UpdateUser", 	new DefaultSLObjectRenderer(), null, 12 ) );

    columnMaster.put( new Integer(BASE_CURRENCY), new SLColumnDefinition( BASE_CURRENCY, "BaseCCY", "BaseCCY", new DefaultSLObjectRenderer(), null, 6) );

    columnMaster.put( new Integer(BASE_CCY_VALUE), new SLColumnDefinition( BASE_CCY_VALUE, "BaseCcyValue", "BaseCcy Value", new SLNumberRenderer( JPVTable.DOUBLE, 12, 2 ), null, 14 ) );

    columnMaster.put( new Integer(COLLAT_SETTLE_DATE), new SLColumnDefinition( COLLAT_SETTLE_DATE, "CltDate",  "Clt Date", 	new SLDateRenderer(), null, 9 ) );

    columnMaster.put( new Integer(COLLAT_SETTLE_MODE), new SLColumnDefinition( COLLAT_SETTLE_MODE, "CltMode",  "Clt Mode", 	new DefaultSLObjectRenderer(), null, 8 ) );

    columnMaster.put( new Integer(STATUS), new SLColumnDefinition( STATUS, "Status", "Status", new DefaultSLObjectRenderer(), null, 5 ) );

    columnMaster.put( new Integer(BIZDAY), new SLColumnDefinition( BIZDAY, "BizDay", "Biz Date", new SLDateRenderer(), null, 9 ) );

    columnMaster.put( new Integer(CA_REC_DATE), new SLColumnDefinition( CA_REC_DATE, "CARecDate", "CA Rec Date", new SLDateRenderer(), null, 9 ) );

    columnMaster.put( new Integer(CA_TYPE), new SLColumnDefinition( CA_TYPE, "CaType", "CA Type", new DefaultSLObjectRenderer(), null, 8 ) );

    columnMaster.put( new Integer(CUM_EX), new SLColumnDefinition( CUM_EX, "CumExDivFlag", "Cum/Ex", new DefaultSLObjectRenderer(), null, 5 ) );

    columnMaster.put( new Integer(IMG_REF), new SLColumnDefinition( IMG_REF, "IMGRef", "IMG Ref", new DefaultSLObjectRenderer(), null, 8 ) );

    columnMaster.put( new Integer(COF_ADJ), new SLColumnDefinition( COF_ADJ, "CofAdj", "COF Adj", new SLNumberRenderer( JPVTable.DOUBLE, 12, 4 ), new SLNumberEditor(true), 12 ) );

    columnMaster.put( new Integer(SCRIPT_ELECTION), new SLColumnDefinition( SCRIPT_ELECTION, "ScriptElection", "Script Election", new DefaultSLObjectRenderer(), null, 16 ) );
    //columnMaster.put( new Integer(BARGAIN_REF), new SLColumnDefinition( BARGAIN_REF, "LoanetRef",  "Loanet Ref", 	new DefaultSLObjectRenderer(), null, 12 ) );

    columnMaster.put( new Integer(ORG_SETTLE_DATE), new SLColumnDefinition( ORG_SETTLE_DATE, "OrgSettleDate",  "Org Settle Date", new SLDateRenderer(), null, 9 ) );
    columnMaster.put( new Integer(CREST_FOP), new SLColumnDefinition( CREST_FOP, "CRESTFOP",  "CRESTFOP", new DefaultSLObjectRenderer(), null, 9 ) );

    columnMaster.put( new Integer(EXCH_COUNTRY), new SLColumnDefinition( EXCH_COUNTRY, "ExchCntry", "Exch Cntry", new DefaultSLObjectRenderer(), null, 4 ) );

    columnMaster.put( new Integer(ACCOUNT), new SLColumnDefinition( ACCOUNT, "Account", "Account", new DefaultSLObjectRenderer( JPVTable.TEXT_NULL ), null, 9 ) );

    columnMaster.put( new Integer(ACCOUNTNAME), new SLColumnDefinition( ACCOUNTNAME, "AccountName", "Account Name", new DefaultSLObjectRenderer( JPVTable.TEXT_NULL ), null, 20 ) );

    columnMaster.put( new Integer(P_AND_L), new SLColumnDefinition( P_AND_L, "PANDL", "P / L ", new SLNumberRenderer( JPVTable.DOUBLE, 10, 2 ), null, 10 ) );

    columnMaster.put( new Integer(SPECIAL_FLAG), new SLColumnDefinition( SPECIAL_FLAG, "Special", "Special", new DefaultSLObjectRenderer( JPVTable.BOOLEAN ), null, 5 ) );

    columnMaster.put( new Integer(CLASSIFICATION), new SLColumnDefinition( CLASSIFICATION, "Classification", "Classification", new DefaultSLObjectRenderer( JPVTable.TEXT_NULL ), null, 15 ) );
    
    columnMaster.put( new Integer(REPO_TO), new SLColumnDefinition( REPO_TO, "RepoTo", "RepoTo", new DefaultSLObjectRenderer( JPVTable.TEXT_NULL ), null, 15 ) );
    
    columnMaster.put( new Integer(REPO_FROM), new SLColumnDefinition( REPO_FROM, "RepoFrom", "RepoFrom", new DefaultSLObjectRenderer( JPVTable.TEXT_NULL ), null, 15 ) );
    columnMaster.put(new Integer(BB_TICKER), new SLColumnDefinition(
			BB_TICKER, "bbticker", "BB_TICKER",
			new DefaultSLObjectRenderer(JPVTable.TEXT_NULL), null, 15));
    /* Written by CGI India (Tamil/Aparna)
    String options[] = {"Exclude","Include"};
    JComboBox jcb = new JComboBox (options);
    pv.jfcx.PVTableEditor jcbEditor = new pv.jfcx.PVTableEditor(jcb, JPVTable.COMBO);
    columnMaster.put( new Integer(SEC_OPTIONS), new SLColumnDefinition(SEC_OPTIONS,"Exclude", "Exclude",new RowRenderer1 (JPVTable.COMBO), jcbEditor, null, 10));
    
    columnMaster.put( new Integer(SEC_EXPDATE), new SLColumnDefinition(SEC_EXPDATE,"EXPIRYDATE", "ExpiryDate", new DefaultSLObjectRenderer(), null, 8));
    
    ------------------------------------------------------------------------------------*/
//  cgi start added for Data ExploreWindow 
    columnMaster.put( new Integer(WEIGHTED_AVERAGE_FEE), new SLColumnDefinition( WEIGHTED_AVERAGE_FEE, "WeightedAvgFee", "Weighted Avg Fee", new SLNumberRenderer( JPVTable.DOUBLE, 10, 4 ), null, 15 ) );
    columnMaster.put( new Integer(LAST_TRADE_DATE), new SLColumnDefinition( LAST_TRADE_DATE, "LastTradeDate", "Last Trade Date", new SLDateRenderer(), null, 10 ) );
    columnMaster.put( new Integer(LAST_TRADE_QUANTITY), new SLColumnDefinition( LAST_TRADE_QUANTITY, "LastTradeQty", "Last Trade Qty", new SLNumberRenderer( JPVTable.DOUBLE, 10 ), null, 15 ) );
    

    columnMaster.put( new Integer(LAST_TRADE_REBATE_RATE), new SLColumnDefinition( LAST_TRADE_REBATE_RATE, " Rebate Rate", " Rebate Rate", new SLNumberRenderer( JPVTable.DOUBLE, 10, 4), null, 15 ) );
    
   
    columnMaster.put( new Integer(UTILIZATION_AGE), new SLColumnDefinition( UTILIZATION_AGE, "UtilizationAge", "Utilization%age", new SLNumberRenderer( JPVTable.DOUBLE, 10, 2 ), null, 15 ) );
    
    columnMaster.put( new Integer(RICCODE), new SLColumnDefinition( RICCODE, "RicCode", "Ric", new DefaultSLObjectRenderer( JPVTable.TEXT_NULL ), null, 10 ) );
    columnMaster.put( new Integer(CUSIP), new SLColumnDefinition( CUSIP, "CuSip", "CUSIP", new DefaultSLObjectRenderer( JPVTable.TEXT_NULL ), null, 10 ) );
    columnMaster.put( new Integer(SEDOL), new SLColumnDefinition( SEDOL, "Sedol", "SEDOL", new DefaultSLObjectRenderer( JPVTable.TEXT_NULL ), null, 10 ) );
    //columnMaster.put( new Integer(SEID), new SLColumnDefinition( SEID, "Seid", "SEID", new DefaultSLObjectRenderer( JPVTable.TEXT_NULL ), null, 10 ) ); 
    columnMaster.put( new Integer(ISIN), new SLColumnDefinition( ISIN, "Isin", "ISIN", new DefaultSLObjectRenderer( JPVTable.TEXT_NULL ), null, 15 ) );

    // cgi end added for Data ExploreWindow 
//cgi added for DataExplorer AnalyticsPanel

		columnMaster.put(new Integer(DE_AVAILABILITY), new SLColumnDefinition(
				DE_AVAILABILITY, "DeAvailability", "DE Availability",
				new SLNumberRenderer(JPVTable.DOUBLE, 10, 0), null, 15));
		columnMaster.put(new Integer(DB_AVAILABILITY), new SLColumnDefinition(
				DB_AVAILABILITY, "DBAvailability", "DB Availability",
				new SLNumberRenderer(JPVTable.DOUBLE), null, 15));
		columnMaster.put(new Integer(DE_UTILIZATION), new SLColumnDefinition(
				DE_UTILIZATION, "DeUtilisation", "DE Utilisation",
				new SLNumberRenderer(JPVTable.DOUBLE, 10, 4), null, 15));
		columnMaster.put(new Integer(DB_AGEOFMARKET), new SLColumnDefinition(
				DB_AGEOFMARKET, "DBofmarket", "DB %age of market",
				new SLNumberRenderer(JPVTable.DOUBLE, 10, 2), null, 15));
		columnMaster
				.put(new Integer(DE_WEIGHTED_AVERAGE_FEE),
						new SLColumnDefinition(DE_WEIGHTED_AVERAGE_FEE,
								"DeWeightedAverageFee",
								"DE Weighted Average Fee",
								new SLNumberRenderer(JPVTable.DOUBLE, 10, 4),
								null, 15));
		columnMaster.put(new Integer(DE_MOST_RECENT_EFEE),
				new SLColumnDefinition(DE_MOST_RECENT_EFEE, "DEmostRecentFee",
						"DE Most Recent Fee", new SLNumberRenderer(
								JPVTable.DOUBLE, 10, 4), null, 15));
		columnMaster.put(new Integer(DB_MOST_RECENT_EFEE),
				new SLColumnDefinition(DB_MOST_RECENT_EFEE, "DBmostRecentFee",
						"DB Most Recent Fee", new SLNumberRenderer(
								JPVTable.DOUBLE, 10, 4), null, 15));
		columnMaster.put(new Integer(DB_FEE), new SLColumnDefinition(DB_FEE,
				"DBFeevsStreetVariance", "DB Fee vs Street Variance",
				new SLNumberRenderer(JPVTable.DOUBLE, 10, 2), null, 15));
		columnMaster.put(new Integer(AVG_BORROW_AGE), new SLColumnDefinition(
				AVG_BORROW_AGE, "AvgBorrowAge(Tenure)",
				"Avg Borrow Age (Tenure)(In Days)", new SLNumberRenderer(
						JPVTable.INTEGER, 10, 0), null, 15));
		columnMaster.put(new Integer(DB_FEE_DESPIRSON), new SLColumnDefinition(
				DB_FEE_DESPIRSON, "DBFeeDispersion", "DB Fee Dispersion",
				new DefaultSLObjectRenderer(JPVTable.TEXT_NULL), null, 15));
		columnMaster.put(new Integer(NET_DIV_DESPIRSON),
				new SLColumnDefinition(NET_DIV_DESPIRSON,
						"NetDivageDispersion", "Net Div %age Dispersion",
						new DefaultSLObjectRenderer(JPVTable.TEXT_NULL), null,
						15));
		columnMaster.put(new Integer(NET_DIV), new SLColumnDefinition(NET_DIV,
				"NetDiv", "Net Div %", new DefaultSLObjectRenderer(
						JPVTable.TEXT_NULL), null, 15));
		columnMaster.put(new Integer(AGE_UTILIZATION), new SLColumnDefinition(
				AGE_UTILIZATION, "ageUtilization", "%age Of Utilization",
				new DefaultSLObjectRenderer(JPVTable.TEXT_NULL), null, 15));
		columnMaster.put(new Integer(RATE_CHANGE), new SLColumnDefinition(
				RATE_CHANGE, "RateChange", "Rate Change",
				new SLNumberRenderer(JPVTable.DOUBLE, 10, 4), null, 15));
		columnMaster.put(new Integer(SHORTS_DB_UTILIZATION), new SLColumnDefinition(SHORTS_DB_UTILIZATION,
				"ShortsDBUtilisation", "Shorts DBUtilisation",
				new SLNumberRenderer(JPVTable.DOUBLE, 10, 4), null, 15));
		columnMaster.put(new Integer(DE_HEIGHEST_FEE), new SLColumnDefinition(DE_HEIGHEST_FEE,
				"DEHighestFee", "DEHighestFee",
				new SLNumberRenderer(JPVTable.DOUBLE, 10, 2), null, 15));
		
		columnMaster.put(new Integer(DB_MOST_RECENT_TRADE_SEIZE), new SLColumnDefinition(DB_MOST_RECENT_TRADE_SEIZE,
				"DEMostRecentTradeSize", "DE Most Recent Trade Size",
				new SLNumberRenderer(JPVTable.DOUBLE, 10, 0), null, 15));
		columnMaster.put(new Integer(SEID), new SLColumnDefinition(SEID,
				"Seid", "Seid",
				new SLNumberRenderer(JPVTable.DOUBLE, 10, 0), null, 15));
		
	//cgi added for DataExplorer AnalyticsPanel	 end
		
		
		
    
    for(Enumeration en = columnMaster.elements(); en.hasMoreElements(); ) {
       SLColumnDefinition cd = (SLColumnDefinition) en.nextElement();
       columnMasterByIdName.put( cd.getIdName(), cd );
    }

  }


  protected Hashtable	byId;
  protected Hashtable	byIdName;

  /**	vector of current column definitions	*/
  protected Vector    colDefs;

  public SLColumnManager()
  {
    byId = new Hashtable();
    byIdName = new Hashtable();
    colDefs	= new Vector();
  }


  public static SLColumnDefinition getColumnDef( int id )
  {
    return (SLColumnDefinition)columnMaster.get( new Integer( id ) );
  }

  public static SLColumnDefinition getColumnDef( String idName )
  {
    return (SLColumnDefinition)columnMasterByIdName.get( idName );
  }


  //	use JPVTable column type
  public void put( int		id,
                   String	idName,
                   String	displayLabel,
                   int		colType,
                   int		displayWidth )
  {
    SLColumnDefinition cd = new SLColumnDefinition( id,
                                                    idName,
                                                    displayLabel,
                                                    colType,
                                                    displayWidth );
    put( cd );

  }

  public void put( int			id,
                   String		idName,
                   String		displayLabel,
                   PVTableRenderer	renderer,
                   int			displayWidth )
  {
    SLColumnDefinition cd = new SLColumnDefinition( id,
                                                    idName,
                                                    displayLabel,
                                                    renderer,
                                                    null,
                                                    displayWidth );
    put( cd );
  }



  public void put( int			id,
                   String		idName,
                   String		displayLabel,
                   PVTableRenderer	renderer,
                   TableCellEditor	editor,
                   int			displayWidth )
  {
    SLColumnDefinition cd = new SLColumnDefinition( id,
                                                    idName,
                                                    displayLabel,
                                                    renderer,
                                                    editor,
                                                    displayWidth );
    put( cd );
  }

  /**
   * add column definition to hashtables: byId and byName.
   * Parametes include individual values for SLColumnDefinition
   */

  public void put( int			id,
                   String		idName,
                   String		displayLabel,
                   PVTableRenderer	renderer,
                   TableCellEditor	editor,
                   int			displayWidth,
                   boolean		editable )
  {
    SLColumnDefinition cd = new SLColumnDefinition( id,
                                                    idName,
                                                    displayLabel,
                                                    renderer,
                                                    editor,
                                                    displayWidth,
                                                    editable );
    put( cd );
  }

  /**
   * add column definition to hashtables: byId and byName.
   * @param cd	column definition object
   */
  public void put( SLColumnDefinition cd )
  {
    colDefs.add( cd );
    byId.put( new Integer( cd.getId() ), cd );
    if( cd.getIdName() != null )
      byIdName.put( cd.getIdName(), cd );
  }

    /**
     *	return Column definition by ID
     * @param id column id( integer value )
     */
  public SLColumnDefinition getById( int id )
  {
    Integer ID = new Integer( id );

    if( id < COLUMN_ID_START )
      return ( SLColumnDefinition )byId.get( ID );
    else
      return ( SLColumnDefinition )columnMaster.get( ID );
  }


  public SLColumnDefinition getByIdName( String idName )
  {
    /*SLColumnDefinition cd = ( SLColumnDefinition )columnMasterByIdName.get( idName );

    if (cd == null) {
        cd = ( SLColumnDefinition )byIdName.get( idName );
    }
    */

    SLColumnDefinition cd = ( SLColumnDefinition )byIdName.get( idName );
    if( cd == null )
      cd = ( SLColumnDefinition )columnMasterByIdName.get( idName );

    return cd;
  }


  /**
   *	@param	id	column integer ID
   *	@return clone of the column definition object
   */
  public SLColumnDefinition getByIdClone( int id )
  {
    SLColumnDefinition ret = null;

    SLColumnDefinition cd = getById( id );

    if( cd == null )
    {
      Util.error( "SLColumnManager.getByIdClone(): could not find column ID: " + id );
      return null;
    }

    try
    {
      ret = ( SLColumnDefinition )cd.clone();
    }
    catch( Exception e )
    {
      Util.error( "SLColumnManager.getByIdClone()", e.getMessage() );
    }
    return ret;
  }


  public SLColumnDefinition getByIdNameClone( String idName )
  {
    SLColumnDefinition ret = null;
    SLColumnDefinition cd = getByIdName( idName );

    if( cd == null )
    {
      Util.error( "SLColumnManager.getByIdNameClone(): could not find column name: " + idName );
      return null;
    }

    try
    {
      ret = ( SLColumnDefinition )cd.clone();
    }
    catch( Exception e )
    {
      Util.error( "Caught exception in SLColumnManager.getByIdNameClone(): " + e.getMessage() );
    }
    return ret;
  }

  public int getColumnCount() { return byId.size(); }

  public Iterator iterator()
  {
   return colDefs.iterator();
  }


  public Vector getColumnDefs()
  {
    return colDefs;
  }

}

